home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Windows.c
-
- Contains: Handle application's windows
-
- Written by: Chris White, Developer Technical Support
-
- Copyright: © 1996 by Apple Computer, Inc., all rights reserved.
-
- Change History (most recent first):
-
- 1/22/96 CW First release
-
- */
-
-
-
- #pragma segment Core
-
-
-
- // System Includes
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __WINDOWS__
- #include <Windows.h>
- #endif
-
- #ifndef __QUICKDRAW__
- #include <Quickdraw.h>
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef __FONTS__
- #include <Fonts.h>
- #endif
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #ifndef __ERRORS__
- #include <Errors.h>
- #endif
-
-
-
-
- // Application Includes
-
- #ifndef __BAREBONES__
- #include "BareBones.h"
- #endif
-
- #ifndef __PROTOTYPES__
- #include "Prototypes.h"
- #endif
-
-
-
-
- // Static prototypes
-
-
-
-
-
-
- void DoActivate ( EventRecord* theEvent )
- {
- Boolean bActiveFlag = theEvent->modifiers & resumeFlag;
- SInt16 ignoreItem;
- WindowRef ignoreWindow;
- WindowRef theWindow = (WindowRef) theEvent->message;
- GrafPtr savePort;
-
-
- GetPort ( &savePort );
- SetPortWindowPort ( theWindow );
- DialogSelect ( theEvent, &ignoreWindow, &ignoreItem );
- SetPort ( savePort );
-
- return;
- }
-
-
-
- void DoUpdate ( EventRecord* theEvent )
- {
- OSErr theErr;
- GrafPtr savePort;
- CGrafPtr thePort;
- WindowRef theWindow = (WindowRef) theEvent->message;
- RgnHandle theRgn;
-
-
-
- theRgn = NewRgn ( );
- theErr = MemError ( );
- if ( theErr ) goto CleanupAndBail;
-
- GetPort ( &savePort );
- SetPortWindowPort ( theWindow );
- BeginUpdate ( theWindow ); // visRgn temporarily = updateRgn
-
- thePort = GetWindowPort ( theWindow );
- UpdateDialog ( theWindow, thePort->visRgn );
- DisposeRgn ( theRgn );
-
- EndUpdate ( theWindow ); // restore normal visRgn of grafport
- SetPort ( savePort );
-
- CleanupAndBail:
-
- return;
- }
-
-
-
- void DoContentClick ( WindowRef theWindow, EventRecord* theEvent )
- {
- WindowRef frontWindow;
-
- // If a movable modal is active, ignore click in an inactive
- // window, otherwise select it or handle the content click.
-
- frontWindow = FrontWindow ( );
- if ( theWindow != frontWindow )
- {
- if ( IsMovableModal ( frontWindow ) )
- SysBeep ( 30 );
- else
- SelectWindow ( theWindow );
- }
- else
- {
- SInt16 itemHit;
-
- if ( DialogSelect ( theEvent, &theWindow, &itemHit ) && itemHit == 1 )
- {
- tThreadedOperationPtr theInfo;
-
- theInfo = (tThreadedOperationPtr) GetWRefCon ( theWindow );
- theInfo->bCancelled = true;
- }
- }
-
- return;
-
- } // DoContentClick
-
-
-
- void DoDragWindow ( WindowRef theWindow, EventRecord* theEvent )
- {
- WindowRef frontWindow;
-
-
- // If a movable modal is active, ignore click in an inactive
- // title bar, otherwise let the Window Manager handle it.
-
- frontWindow = FrontWindow ( );
- if ( theWindow != frontWindow && IsMovableModal ( frontWindow ) )
- SysBeep ( 30 );
- else
- {
- RgnHandle theRgn;
- Rect dragRect;
-
- theRgn = GetGrayRgn ( );
- dragRect = (*theRgn)->rgnBBox;
- DragWindow ( theWindow, theEvent->where, &dragRect );
- }
-
- return;
- }
-
-
-
-
-
-